package ar.uba.tleng.g99.expregs.parser;

import java.util.Set;

import ar.uba.tleng.g99.expregs.automata.AutomataND;

public final class AsteriskExpr implements Expr {

	private final Expr expr;

	public AsteriskExpr(Expr expr) {
		this.expr = expr;
	}
	
	@Override
	public AutomataND automata(Set<Character> sigma) {
		return AutomataND.asterisk(sigma, this.expr.automata(sigma));
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((expr == null) ? 0 : expr.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AsteriskExpr other = (AsteriskExpr) obj;
		if (expr == null) {
			if (other.expr != null)
				return false;
		} else if (!expr.equals(other.expr))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "AsteriskExpr [expr=" + expr + "]";
	}	
}
